﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RegistrationForm
{
    public partial class Register : System.Web.UI.Page
    {
        List<Student> students = new List<Student>();
    
        protected void registerButton_Click(object sender, EventArgs e) 
        {
            Student newStudent = new Student();
            newStudent.firstName = this.firstName.Text;
            newStudent.lastName = this.lastName.Text;
            newStudent.facNumber = this.facultyNumber.Text;
            newStudent.university = this.university.SelectedItem.Text;
            newStudent.courses = new List<string>();
            for (int i = 0; i < this.courses.Items.Count; i++) 
            {
                if (this.courses.Items[i].Selected == true) 
                {
                    newStudent.courses.Add(this.courses.Items[i].Text);
                }
            }

            students.Add(newStudent);
            foreach (Student student in students)
            {
                this.mainPanel.Controls.Add(new LiteralControl("<h1>" + student.firstName + " " + student.lastName + "</h1>"));
                this.mainPanel.Controls.Add(new LiteralControl("<p>" + student.facNumber + "</p>"));
                this.mainPanel.Controls.Add(new LiteralControl("<p>" + student.university + "</p>"));
                this.mainPanel.Controls.Add(new LiteralControl("<h2>Courses</h2>"));
                foreach (var course in student.courses)
                {
                    this.mainPanel.Controls.Add(new LiteralControl("<p>" + course + "</p>"));
                }
            }
            
            //tva e tolkova zle che po-dobre ne go gledaide :D
        }
    }
}